<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" href="main.css" type="text/css" media="all"/> 
	<title>JIPDA - conc</title>
	<script type="text/javascript" src="../jipda/lib/esprima.js"></script>
	<script type="text/javascript" src="../jipda/common.js"></script>
	<script type="text/javascript" src="../jipda/lattice/lattice.js"></script>
	<script type="text/javascript" src="../jipda/lattice/cpLattice.js"></script>
	<script type="text/javascript" src="../jipda/address/address.js"></script>
	<script type="text/javascript" src="../jipda/address/concreteAg.js"></script>
	<script type="text/javascript" src="../jipda/benv/defaultBenv.js"></script>
	<script type="text/javascript" src="../jipda/state.js"></script>
	<script type="text/javascript" src="../jipda/ast.js"></script>
	<script type="text/javascript" src="../jipda/visited.js"></script>
	<script type="text/javascript" src="../jipda/eval.js"></script>
	<script type="text/javascript" src="../jipda/jipda.js"></script>
	<script type="text/javascript" src="../jipda/dep.js"></script>
	<script type="text/javascript" src="../jipda/transform.js"></script>
	<script type="text/javascript" src="lib/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="lib/ace/ace.js"></script>
	<script type="text/javascript">

		// define print method for JIPDA
    var print = function () { console.log(Array.prototype.slice.call(arguments).join(" ")) }		
		var editor;
		
		 function Printer(store)
		 {
		   this.store = store;
		 }
		 Printer.prototype.visitJipdaValue =
		   function (x)
		   {
		     var printedUser = x.user.accept(this);
		     var printedAddresses = x.addresses().map(Visitor.accept(this));
		     return ([printedUser].concat(printedAddresses)).toString();
		   }
		 Printer.prototype.visitBOT =
		   function (x)
		   {
		     return "_";
		   }

 
		function doIt()
		{
			//$("#depGraph").empty();
			$("#resultValue").empty();
		  var source = editor.getSession().getValue();
			var ast = createAst(source);
			var lat = new CpLattice();
		  var concreteVisited = {};
		  concreteVisited.visited = function (node, stack, benva, store, time) { return {store:store, stack:stack} };
			var jipda = new Jipda({lattice: lat, k:0, ag:concreteAg, visited:concreteVisited});
			var result = jipda.evalNode(ast);
			var value = result.map(State.topOfStack).reduce(Lattice.join, BOT);
			$("#resultValue").text(value);
		}
			
		$(function ()
		{
		  editor = ace.edit("editor");
		  editor.getSession().setMode("ace/mode/javascript");
		})
		
	</script>
</head>

<body>
	<div id="editor" style="width: 640px; height: 480px;"></div>
	<div id="manip" style="position: absolute; top:490px;">
		<button id="eval" name="eval" onClick="doIt()">Eval</button>
		<span id="resultValue"></span>
	</div>
	<div id="params" style="position:absolute; left:400px; width:400px; height:480px;"/>
</body>

</html>
</html>
</html>